{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=155
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var
	n,k,i:longint;
	a:array[0..10] of longint;
 
procedure go(i,v:longint);
 
var
	j:longint;
 
begin
a[i]:=v;
if i<n then
	for j:=1 to k do
		go(i+1,j)
else 
if i=n then begin 
	for j:=1 to n do
		write(a[j],' ');
	writeln;
end;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n,k);
for i:=1 to k do
	go(1,i);
end.